from google.appengine.ext import db

#stores Zipped JSON tree objects
#Created on 'Save' of the tree, until then, the tree is stored in a temp table
class treeStore(db.Model):
  objId = db.StringProperty() #The unique key for the object, perm9c63a1c1-9d89-4562-97cf-b1a479e56460
  objBlob = db.BlobProperty() #A zipped string of the PhyloJSON object
  userName = db.StringProperty() #the userName is provided by Google and is the Google signin name
  userNameShort = db.StringProperty() #a nickname provided by Google
  forkedObj = db.StringProperty(default=None) #objId of the tree from which this was forked
  originalAuthor = db.StringProperty() #The userName of the author who FIRST created the tree
  last_access_date = db.DateTimeProperty(auto_now_add=True)
  last_update_date = db.DateTimeProperty(auto_now_add=True)
  downloadCt = db.IntegerProperty(default=1) #Track how popular the tree is
  hasWidget = db.BooleanProperty(default=False) #Track how popular the tree is
  version = db.StringProperty(default="1-0") #The version of our app that made this tree

class treeOwners(db.Model):
  objId = db.StringProperty() #The unique key for the object, perm9c63a1c1-9d89-4562-97cf-b1a479e56460
  userName = db.StringProperty() #the userName is provided by Google and is the Google signin name
    
    
#used to store a tree for temporary sessions
class tmpStore(db.Model):
  objId = db.StringProperty()
  objBlob = db.BlobProperty()
  userName = db.StringProperty()
  originalAuthor = db.StringProperty()
  last_access_date = db.DateTimeProperty(auto_now_add=True)
  
#stores Zipped JSON objects with instructions for recreating a tree
#with all the same methods used previously
#i'm not certain how we will handle this, but if we can figure it out,
#it will be a huge add
"""
class treePresets(db.Model):
  treeId = db.StringProperty()
  treeBlob = db.BlobProperty()
  treeKey = db.StringProperty()
"""
